<template>
  <view class="">
    <u-tabs
      :list="list"
      :is-scroll="false"
      :current="current"
      @change="change"
    ></u-tabs>
    <view class="" v-if="current == 0">
      <tradeComponent :merchantNo="merchantNo"></tradeComponent>
    </view>
    <view class="" v-else>
      <infoComponent :merchantNo="merchantNo"></infoComponent>
    </view>
  </view>
</template>

<script>
import tradeComponent from './component/tradeComponent.vue';
import infoComponent from './component/infoComponent.vue';
export default {
  components: {
    infoComponent,
    tradeComponent,
  },
  data() {
    return {
      merchantNo: '',
      list: [
        {
          name: '交易详情',
        },
        {
          name: '信息详情',
        },
      ],
      current: 0,
    };
  },
  // onLoad自带一个参数
  onLoad(options) {
    // 确保在 onLoad 中获取参数
    if (options && options.merchantNo) {
      this.merchantNo = options.merchantNo;
      console.log('this.merchantNo----->42', this.merchantNo);
    } else {
      console.error('未能获取商户编号');
    }

    // this.merchantNo = this.$route.query.merchantNo;
  },
  // mounted() {
  //   console.log('this.$route----->', this.$route);
  //   this.merchantNo = this.$route.query.merchantNo;
  //   console.log('this.merchantNo----->42', this.merchantNo);
  // },
  methods: {
    change(index) {
      this.current = index;
    },
  },
};
</script>

<style></style>
